/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.collections.FXCollections
 *  javafx.collections.ObservableList
 *  javafx.event.ActionEvent
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.Node
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.CheckBox
 *  javafx.scene.control.TableCell
 *  javafx.scene.control.TableColumn
 *  javafx.scene.control.TableView
 *  javafx.scene.control.cell.PropertyValueFactory
 *  javafx.scene.layout.AnchorPane
 *  javafx.util.Callback
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.util.CollectionUtils
 */
package com.gys.controller.clearBox;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.ExamineTipUtil;
import com.gys.common.data.HttpJson;
import com.gys.controller.BaseController;
import com.gys.controller.clearBox.ClearBoxController;
import com.gys.controller.dataManger.ControllerManger;
import com.gys.data.clearBox.ClearBoxInfoOutData;
import com.gys.data.clearBox.ExamineTipOutData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.util.Callback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;

@FXMLController
public class ExamineTipController
extends BaseController
implements Initializable {
    @FXML
    private AnchorPane pane;
    @FXML
    private TableView<ExamineTipOutData> tableView;
    @FXML
    private TableColumn<ExamineTipOutData, String> gsehDate;
    @FXML
    private TableColumn<ExamineTipOutData, CheckBox> checkBox;
    @FXML
    private TableColumn<ExamineTipOutData, String> gsehType;
    @FXML
    private TableColumn<ExamineTipOutData, String> gsehVoucherId;
    @FXML
    private TableColumn<ExamineTipOutData, String> gsehTotalAmt;
    @FXML
    private TableColumn<ExamineTipOutData, String> gsehTotalQty;
    @Autowired
    ClearBoxController clearBoxController;
    ClearBoxInfoOutData clearBoxInfoOutData = null;
    private ObservableList<ExamineTipOutData> observableTableList = FXCollections.observableArrayList(new ArrayList());

    public void initialize(URL location, ResourceBundle resources) {
        ControllerManger.controllerMap.put(this.getClass().getSimpleName(), this);
        this.bingTableCell();
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.pane)) {
            return;
        }
        this.clearBoxInfoOutData = null;
        this.initTableView();
    }

    private void initTableView() {
        List dataList = new ArrayList();
        HashMap<String, Object> param = new HashMap<String, Object>();
        HttpJson httpJson = ExamineTipUtil.selectList(param);
        if (!httpJson.isSuccess()) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", httpJson.getMsg());
            alert.showAndWait();
            return;
        }
        dataList = JSON.parseArray((String)httpJson.getMsg(), ExamineTipOutData.class);
        this.observableTableList.clear();
        if (ObjectUtil.isNotEmpty(dataList)) {
            this.observableTableList = FXCollections.observableArrayList(dataList);
        }
        this.bingTableCell();
        this.tableView.setItems(this.observableTableList);
        this.checkBox.setCellValueFactory(cellData -> ((ExamineTipOutData)cellData.getValue()).getCheckBox().getCustomCheckBox());
        this.initCheckBox();
    }

    public void initCheckBox() {
        this.checkBox.setCellFactory(col -> {
            TableCell<ExamineTipOutData, CheckBox> cell = new TableCell<ExamineTipOutData, CheckBox>(){

                protected void updateItem(CheckBox item, boolean empty) {
                    super.updateItem(item, empty);
                    this.setGraphic((Node)item);
                    if (item != null) {
                        item.setOnMouseClicked(col -> {
                            if (CollectionUtils.isEmpty((Collection)ExamineTipController.this.observableTableList)) {
                                return;
                            }
                            int index = this.getIndex();
                            for (int i = 0; i < ExamineTipController.this.observableTableList.size(); ++i) {
                                if (i == index) continue;
                                ((ExamineTipOutData)ExamineTipController.this.observableTableList.get(i)).getCheckBox().setSelectStatus(false);
                            }
                        });
                    }
                }
            };
            return cell;
        });
    }

    private void bingTableCell() {
        this.checkBox.setCellValueFactory((Callback)new PropertyValueFactory(this.checkBox.getId()));
        this.gsehDate.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehDate.getId()));
        this.gsehType.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehType.getId()));
        this.gsehVoucherId.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehVoucherId.getId()));
        this.gsehTotalAmt.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehTotalAmt.getId()));
        this.gsehTotalQty.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehTotalQty.getId()));
    }

    @FXML
    private void sureAction(ActionEvent event) {
        this.observableTableList.forEach(item -> {
            if (item.getCheckBox().isSelected().booleanValue()) {
                HashMap<String, Object> param = new HashMap<String, Object>();
                param.put("gsehVoucherId", item.getGsehVoucherId());
                param.put("gsahVoucherId", item.getGsahVoucherId());
                HttpJson httpJson = ExamineTipUtil.getClearBoxInfo(param);
                if (httpJson.isSuccess()) {
                    this.clearBoxInfoOutData = (ClearBoxInfoOutData)JSON.parseObject((String)httpJson.getMsg(), ClearBoxInfoOutData.class);
                    this.cancelAction();
                    this.clearBoxController.clearBoxByExa(this.clearBoxInfoOutData.getGschVoucherId());
                } else {
                    Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", httpJson.getMsg());
                    alert.showAndWait();
                }
            }
        });
    }

    @FXML
    private void cancelAction() {
        this.pane.getScene().getWindow().hide();
    }

    public AnchorPane getPane() {
        return this.pane;
    }

    public TableView<ExamineTipOutData> getTableView() {
        return this.tableView;
    }

    public TableColumn<ExamineTipOutData, String> getGsehDate() {
        return this.gsehDate;
    }

    public TableColumn<ExamineTipOutData, CheckBox> getCheckBox() {
        return this.checkBox;
    }

    public TableColumn<ExamineTipOutData, String> getGsehType() {
        return this.gsehType;
    }

    public TableColumn<ExamineTipOutData, String> getGsehVoucherId() {
        return this.gsehVoucherId;
    }

    public TableColumn<ExamineTipOutData, String> getGsehTotalAmt() {
        return this.gsehTotalAmt;
    }

    public TableColumn<ExamineTipOutData, String> getGsehTotalQty() {
        return this.gsehTotalQty;
    }

    public ClearBoxController getClearBoxController() {
        return this.clearBoxController;
    }

    public ClearBoxInfoOutData getClearBoxInfoOutData() {
        return this.clearBoxInfoOutData;
    }

    public ObservableList<ExamineTipOutData> getObservableTableList() {
        return this.observableTableList;
    }

    public void setPane(AnchorPane pane) {
        this.pane = pane;
    }

    public void setTableView(TableView<ExamineTipOutData> tableView) {
        this.tableView = tableView;
    }

    public void setGsehDate(TableColumn<ExamineTipOutData, String> gsehDate) {
        this.gsehDate = gsehDate;
    }

    public void setCheckBox(TableColumn<ExamineTipOutData, CheckBox> checkBox) {
        this.checkBox = checkBox;
    }

    public void setGsehType(TableColumn<ExamineTipOutData, String> gsehType) {
        this.gsehType = gsehType;
    }

    public void setGsehVoucherId(TableColumn<ExamineTipOutData, String> gsehVoucherId) {
        this.gsehVoucherId = gsehVoucherId;
    }

    public void setGsehTotalAmt(TableColumn<ExamineTipOutData, String> gsehTotalAmt) {
        this.gsehTotalAmt = gsehTotalAmt;
    }

    public void setGsehTotalQty(TableColumn<ExamineTipOutData, String> gsehTotalQty) {
        this.gsehTotalQty = gsehTotalQty;
    }

    public void setClearBoxController(ClearBoxController clearBoxController) {
        this.clearBoxController = clearBoxController;
    }

    public void setClearBoxInfoOutData(ClearBoxInfoOutData clearBoxInfoOutData) {
        this.clearBoxInfoOutData = clearBoxInfoOutData;
    }

    public void setObservableTableList(ObservableList<ExamineTipOutData> observableTableList) {
        this.observableTableList = observableTableList;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ExamineTipController)) {
            return false;
        }
        ExamineTipController other = (ExamineTipController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        AnchorPane this$pane = this.getPane();
        AnchorPane other$pane = other.getPane();
        if (this$pane == null ? other$pane != null : !this$pane.equals(other$pane)) {
            return false;
        }
        TableView<ExamineTipOutData> this$tableView = this.getTableView();
        TableView<ExamineTipOutData> other$tableView = other.getTableView();
        if (this$tableView == null ? other$tableView != null : !this$tableView.equals(other$tableView)) {
            return false;
        }
        TableColumn<ExamineTipOutData, String> this$gsehDate = this.getGsehDate();
        TableColumn<ExamineTipOutData, String> other$gsehDate = other.getGsehDate();
        if (this$gsehDate == null ? other$gsehDate != null : !this$gsehDate.equals(other$gsehDate)) {
            return false;
        }
        TableColumn<ExamineTipOutData, CheckBox> this$checkBox = this.getCheckBox();
        TableColumn<ExamineTipOutData, CheckBox> other$checkBox = other.getCheckBox();
        if (this$checkBox == null ? other$checkBox != null : !this$checkBox.equals(other$checkBox)) {
            return false;
        }
        TableColumn<ExamineTipOutData, String> this$gsehType = this.getGsehType();
        TableColumn<ExamineTipOutData, String> other$gsehType = other.getGsehType();
        if (this$gsehType == null ? other$gsehType != null : !this$gsehType.equals(other$gsehType)) {
            return false;
        }
        TableColumn<ExamineTipOutData, String> this$gsehVoucherId = this.getGsehVoucherId();
        TableColumn<ExamineTipOutData, String> other$gsehVoucherId = other.getGsehVoucherId();
        if (this$gsehVoucherId == null ? other$gsehVoucherId != null : !this$gsehVoucherId.equals(other$gsehVoucherId)) {
            return false;
        }
        TableColumn<ExamineTipOutData, String> this$gsehTotalAmt = this.getGsehTotalAmt();
        TableColumn<ExamineTipOutData, String> other$gsehTotalAmt = other.getGsehTotalAmt();
        if (this$gsehTotalAmt == null ? other$gsehTotalAmt != null : !this$gsehTotalAmt.equals(other$gsehTotalAmt)) {
            return false;
        }
        TableColumn<ExamineTipOutData, String> this$gsehTotalQty = this.getGsehTotalQty();
        TableColumn<ExamineTipOutData, String> other$gsehTotalQty = other.getGsehTotalQty();
        if (this$gsehTotalQty == null ? other$gsehTotalQty != null : !this$gsehTotalQty.equals(other$gsehTotalQty)) {
            return false;
        }
        ClearBoxController this$clearBoxController = this.getClearBoxController();
        ClearBoxController other$clearBoxController = other.getClearBoxController();
        if (this$clearBoxController == null ? other$clearBoxController != null : !this$clearBoxController.equals(other$clearBoxController)) {
            return false;
        }
        ClearBoxInfoOutData this$clearBoxInfoOutData = this.getClearBoxInfoOutData();
        ClearBoxInfoOutData other$clearBoxInfoOutData = other.getClearBoxInfoOutData();
        if (this$clearBoxInfoOutData == null ? other$clearBoxInfoOutData != null : !(this$clearBoxInfoOutData).equals(other$clearBoxInfoOutData)) {
            return false;
        }
        ObservableList<ExamineTipOutData> this$observableTableList = this.getObservableTableList();
        ObservableList<ExamineTipOutData> other$observableTableList = other.getObservableTableList();
        return !(this$observableTableList == null ? other$observableTableList != null : !this$observableTableList.equals(other$observableTableList));
    }

    protected boolean canEqual(Object other) {
        return other instanceof ExamineTipController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        AnchorPane $pane = this.getPane();
        result = result * 59 + ($pane == null ? 43 : $pane.hashCode());
        TableView<ExamineTipOutData> $tableView = this.getTableView();
        result = result * 59 + ($tableView == null ? 43 : $tableView.hashCode());
        TableColumn<ExamineTipOutData, String> $gsehDate = this.getGsehDate();
        result = result * 59 + ($gsehDate == null ? 43 : $gsehDate.hashCode());
        TableColumn<ExamineTipOutData, CheckBox> $checkBox = this.getCheckBox();
        result = result * 59 + ($checkBox == null ? 43 : $checkBox.hashCode());
        TableColumn<ExamineTipOutData, String> $gsehType = this.getGsehType();
        result = result * 59 + ($gsehType == null ? 43 : $gsehType.hashCode());
        TableColumn<ExamineTipOutData, String> $gsehVoucherId = this.getGsehVoucherId();
        result = result * 59 + ($gsehVoucherId == null ? 43 : $gsehVoucherId.hashCode());
        TableColumn<ExamineTipOutData, String> $gsehTotalAmt = this.getGsehTotalAmt();
        result = result * 59 + ($gsehTotalAmt == null ? 43 : $gsehTotalAmt.hashCode());
        TableColumn<ExamineTipOutData, String> $gsehTotalQty = this.getGsehTotalQty();
        result = result * 59 + ($gsehTotalQty == null ? 43 : $gsehTotalQty.hashCode());
        ClearBoxController $clearBoxController = this.getClearBoxController();
        result = result * 59 + ($clearBoxController == null ? 43 : $clearBoxController.hashCode());
        ClearBoxInfoOutData $clearBoxInfoOutData = this.getClearBoxInfoOutData();
        result = result * 59 + ($clearBoxInfoOutData == null ? 43 : ($clearBoxInfoOutData).hashCode());
        ObservableList<ExamineTipOutData> $observableTableList = this.getObservableTableList();
        result = result * 59 + ($observableTableList == null ? 43 : $observableTableList.hashCode());
        return result;
    }

    public String toString() {
        return "ExamineTipController(pane=" + this.getPane() + ", tableView=" + this.getTableView() + ", gsehDate=" + this.getGsehDate() + ", checkBox=" + this.getCheckBox() + ", gsehType=" + this.getGsehType() + ", gsehVoucherId=" + this.getGsehVoucherId() + ", gsehTotalAmt=" + this.getGsehTotalAmt() + ", gsehTotalQty=" + this.getGsehTotalQty() + ", clearBoxController=" + this.getClearBoxController() + ", clearBoxInfoOutData=" + this.getClearBoxInfoOutData() + ", observableTableList=" + this.getObservableTableList() + ")";
    }
}

